var oldObjArrayPaymentTracker = new Array();
var setoldObjArrayPaymentTracker = new Array();
//////////////Start Guest Name Page ////////////////
function getReservationRoomPaymentTrackerManageMent(data,valueSearch){
	clearData();
	waitingDialog({});
	var searchName = $("#SearchAll_paymenttrack").val();
	if($("#RowpagerPaymentTrackerListRoomManageMent").val() == null){
		getCurrentTabData().linePaymentTracker= 10;
	}else{
		getCurrentTabData().linePaymentTracker = $("#RowpagerPaymentTrackerListRoomManageMent").val();
	}
	if($("#pagerPaymentTrackerListRoomManageMent").val() == null){
		var pagePointer = 1; 
	}else{
		if(valueSearch!=""&&valueSearch!=undefined){
			var pagePointer = valueSearch; 
		}else{
			var pagePointer = 1;
			getCurrentTabData().pagerNumber = 1;
		}
		//var pagePointer = $("#pagerPaymentTrackerListRoomManageMent").val(); 
	}
	var offfset = (getCurrentTabData().linePaymentTracker*pagePointer)-getCurrentTabData().linePaymentTracker;
	var dataOld =  $("#typeCheckReservationPaymentTrack").val();
	var valueDateCheckin = $("#calendar_btw_checkinPaymentTracker").attr("dateofBtwCheckinPaymentTracker");
	var valueDateCheckout = $("#calendar_btw_checkoutPaymentTracker").attr("dateofBtwCheckoutPaymentTracker");
	if(valueDateCheckin!=""&&valueDateCheckout!=""){
		var dateCheckin = $("#calendar_btw_checkinPaymentTracker").attr("dateofBtwCheckinPaymentTracker");
	  	var dateCheckout = $("#calendar_btw_checkoutPaymentTracker").attr("dateofBtwCheckoutPaymentTracker");
	  	$("#calendar_btw_checkinPaymentTracker").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutPaymentTracker").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinPaymentTracker').attr('dateofBtwCheckinPaymentTracker',dateCheckin);
		$('#calendar_btw_checkoutPaymentTracker').attr('dateofBtwCheckoutPaymentTracker',dateCheckout);
		getCurrentTabData().valueDateCheckin = dateCheckin;
		getCurrentTabData().valueDateCheckout = dateCheckout;
	}else{
		var dateCheckin = new Date().toSystemFormat();
		var dateCheckout= new Date().toSystemFormat();
		$("#calendar_btw_checkinPaymentTracker").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutPaymentTracker").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinPaymentTracker').attr('dateofBtwCheckinPaymentTracker',dateCheckin);
		$('#calendar_btw_checkoutPaymentTracker').attr('dateofBtwCheckoutPaymentTracker',dateCheckout);
		getCurrentTabData().valueDateCheckin = dateCheckin;
		getCurrentTabData().valueDateCheckout = dateCheckout;
	}
	if(data=="PaymentTrackerListRoomManageMent"){
		typeReservationPaymentTrackFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="G"){
		getCurrentTabData().typeReservationPaymentTrack = dataOld;
		typeReservationPaymentTrackFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="S"){
		getCurrentTabData().typeReservationPaymentTrack = dataOld;
		typeReservationPaymentTrackFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data=="A"){
		getCurrentTabData().typeReservationPaymentTrack = dataOld;
		typeReservationPaymentTrackFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName);
	}else if(data == "dateSearch"){
		var dataOld =  $("#typeCheckReservationPaymentTrack").val();
		var valueDateCheckin = $("#calendar_btw_checkinPaymentTracker").attr("dateofBtwCheckinPaymentTracker");
		var valueDateCheckout = $("#calendar_btw_checkoutPaymentTracker").attr("dateofBtwCheckoutPaymentTracker");
		var firstSelect = $("[setoption=typeCheckReservationPaymentTrack]").val();
		if(valueDateCheckin!=""&&valueDateCheckout!=""){
			waitingDialog({});
			var dateCheckin = $("#calendar_btw_checkinPaymentTracker").attr("dateofBtwCheckinPaymentTracker");
			var dateCheckout= $("#calendar_btw_checkoutPaymentTracker").attr("dateofBtwCheckoutPaymentTracker");
			if(dataOld=="G"){
				getCurrentTabData().typeReservationPaymentTrack = dataOld;
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
				}else{
					getCurrentTabData().beforePagePaymentTracker = ""; 
					getCurrentTabData().beforeSubPagePaymentTracker = "";
					var link = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
				}
			}else if(dataOld=="S"){
				getCurrentTabData().typeReservationPaymentTrack = dataOld;
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
				}else{
					getCurrentTabData().beforePagePaymentTracker = ""; 
					getCurrentTabData().beforeSubPagePaymentTracker = "";
					var link = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
				}
			}else if(dataOld=="A"){
				getCurrentTabData().typeReservationPaymentTrack = dataOld;
				if(pagePointer>1){
					var link = "/reservationService?func=getReservationAllPaymentTracker&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					var linkSet = "/reservationService?func=getReservationAllPaymentTracker&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					getCurrentTabData().linkSet = linkSet;
					simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
				}else{
					getCurrentTabData().beforePagePaymentTracker = ""; 
					getCurrentTabData().beforeSubPagePaymentTracker = "";
					var link = "/reservationService?func=getReservationAllPaymentTracker&offset="
						+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
					simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
				}
			}
		}else{
			$("#calendar_btw_checkinPaymentTracker").select();
		}
	}
}
function showDataResRoomPaymentTrackerManageMent(data,output){
	var valueDateCheckin = getCurrentTabData().valueDateCheckin;
	var valueDateCheckout = getCurrentTabData().valueDateCheckout;
	if((valueDateCheckin!=""&&valueDateCheckout!="")&&(valueDateCheckin!=undefined&&valueDateCheckout!=undefined)){
		var dateCheckin = valueDateCheckin;
	  	var dateCheckout = valueDateCheckout;
	  	$("#calendar_btw_checkinPaymentTracker").val($.datepicker.parseDate("yy-mm-dd",dateCheckin).getFormatedString());
		$("#calendar_btw_checkoutPaymentTracker").val($.datepicker.parseDate("yy-mm-dd",dateCheckout).getFormatedString());
		$('#calendar_btw_checkinPaymentTracker').attr('dateofBtwCheckinPaymentTracker',dateCheckin);
		$('#calendar_btw_checkoutPaymentTracker').attr('dateofBtwCheckoutPaymentTracker',dateCheckout);
	}
	// set for pager
	getCurrentTabData().tablePager = "tablepagingPaymentTrack";
	getCurrentTabData().pagerNumberField = "pagerPaymentTrackerListRoomManageMent";
	getCurrentTabData().functionGetData = "getReservationRoomPaymentTrackerManageMent";
	getCurrentTabData().pageName = "PaymentTrackerListRoomManageMent";
	getCurrentTabData().pageNavPosition = "pageNavPositionPaymentTrack";
	getCurrentTabData().trCheck = "trPaymentTrack";
	if(getCurrentTabData().checkinPaymentTrack!=undefined){
		$('#calendar_btw_checkinPaymentTracker').val($.datepicker.parseDate("yy-mm-dd",getCurrentTabData().checkinPendingCheckin).getFormatedString());
		$('#calendar_btw_checkinPaymentTracker').attr('dateofBtwCheckinPaymentTracker',getCurrentTabData().checkinPendingCheckin);
	}
	if(getCurrentTabData().checkoutPaymentTrack!=undefined){
		$('#calendar_btw_checkoutPaymentTracker').val($.datepicker.parseDate("yy-mm-dd",getCurrentTabData().checkinPendingCheckout).getFormatedString());
		$('#calendar_btw_checkoutPaymentTracker').attr('dateofBtwCheckoutPaymentTracker',getCurrentTabData().checkinPendingCheckout);
	}
	if(getCurrentTabData().typeReservationPaymentTrack!=undefined){
		$('#typeCheckReservationPaymentTrack option[value='+getCurrentTabData().typeReservationPaymentTrack+']').attr('selected', 'selected');
	}
	if(data.trim()=="[]"){
		var textDataEmpty = '<tr clearTr="PaymentTackerReservation" >'+
		'<td colspan="100%" style="text-align:center;" >'+
		dataEmpty+
		'</td>'+
		'</tr>';
		textPaymentTracker = textDataEmpty;
		$("[clearTr=PaymentTackerReservation]").remove();
		$("#PaymentTrackerListRoomManageMent_Id_Tr").replaceWith("<tr id=PaymentTrackerListRoomManageMent_Id_Tr ></tr>"+textPaymentTracker);
		textPaymentTracker = '';
	}else{
		$("[clearTr=PaymentTackerReservation]").remove();
		var objArray = new Array();
		if((data=="textSearch"||data=="G"||data=="S"||data=="A")&&data!="dateSearch"){
			objArray 	= oldObjArrayPaymentTracker;
			objArray = objArray[0];
		}else{
			objArray 	= JSON.parse(data);
			oldObjArrayPaymentTracker = objArray;
			objArray = objArray[0];
		}
		var NuberShow = getCurrentTabData().beforePagePaymentTracker; 
		sortIdRoommanagement(objArray);
			var countGroup = 0;
			var OldGroupId =0;
			var OptionReservation = 0;
			var OptionCheckout = 0;
			var OptionCheckIn = 0;
			var emailPic = '<img src=../images/components/roommanagement/email.png alt=Note height=15 width=20>';
			var printPci = '<img src=../images/components/roommanagement/print.png alt=Note height=15 width=20>';
			var firstSelect = "";
			var typeReservation = $("#typeCheckReservationPaymentTrack").val();
			var checkBgColor = 0;
			var checkBgColorG = 0;
			var valueSearch = $("#SearchAll_guestPage").val();
			for(var i =0;i<objArray.length;i++){
				if(objArray[i].name!=""&&objArray[i].name!=undefined){
					var nameReservation = objArray[i].name.split(" ");
				}else{
					var nameReservation = "";
				}
				var Objtitle = objArray[i].reservationTitle;
				var ObjgroupId = objArray[i].groupId;
				var ObjId = objArray[i].id;
				var checkContinue = checkedFilter(output,valueSearch,nameReservation,firstSelect,Objtitle,ObjgroupId,typeReservation,ObjId)
				if(checkContinue==1){
					continue;
				}
				//// SET OPTION STATUS RESERVATION
				var statusOption = objArray[i].reservationTitle;
				if(statusOption=="Reserved Rooms"){
					//OptionReservation++;
				}else if(statusOption=="Checked-out Rooms"){
					OptionCheckout++;
				}else if(statusOption=="Checked-in Rooms"){
					OptionCheckIn++;
				}
				
				if(objArray[i].groupId!="0"){
					if(objArray[i].subList!=undefined){
						if(OldGroupId!=objArray[i].groupIdString){
							//	OldGroupId = objArray[i].groupIdString;
								var setDateFormat = new Date(objArray[i].date);
								var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
								groupId = objArray[i].groupIdString;
								///Check StatusGroup
									var countResIngroup = 0;
									for(var subRes = 0; subRes<objArray[i].subList.length;subRes++){
										var setDateFormatRes = new Date(objArray[i].subList[subRes].date);
										var setFateFormatCheckoutRes = setDateFormatRes.addDate(objArray[i].subList[subRes].span);
										var ShowNameGuest = "";
										/// Name Empty
										if(objArray[i].subList[subRes].name!=undefined){
											ShowNameGuest = objArray[i].subList[subRes].name
										}
										///
										if(objArray[i].subList[subRes].reservationTitle=="Reserved Rooms"){
											StatusResInGroup = statusResv;
										}else if(objArray[i].subList[subRes].reservationTitle=="Checked-out Rooms"){
											StatusResInGroup = statusCheckOut;
										}else if(objArray[i].subList[subRes].reservationTitle=="Temp Rooms"){
											StatusResInGroup = statusTempResv;
										}else if(objArray[i].subList[subRes].reservationTitle=="Cancel Reservation"){
											StatusResInGroup = statusCancelCheckin;
										}else{
											StatusResInGroup = statusCheckin;
										}
										if(checkBgColorG==0){
											statusRecord = 'dataRecordBot';
											checkBgColorG = 1;
										}else{
											statusRecord = 'dataRecordBot';
											checkBgColorG =0;
										}
										var showDisplayGuestname = "";
										if(ShowNameGuest==""){
											showDisplayGuestname = '<tr clearTr=PaymentTackerReservation class="'+statusRecord+'" onclick="if(linkClick==true)noGuestName();"  id="btnEditS" >';
										}else{
											showDisplayGuestname = '<tr clearTr=PaymentTackerReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].subList[subRes].id+')"  id="btnEditS" >';
										}
											NuberShow++;
											textPaymentTracker += showDisplayGuestname+
											'<td class="spanDataCenter">'+
											NuberShow+
											'</td>'+
											'<td class="spanDataCenter">'+
												'<span>G'+objArray[i].groupIdString+'</span>'+
											'</td>'+
											'<td class="spanDataLeft">'+
												'<span class="ownerName" >'+ShowNameGuest+'</span>'+
											'</td>'+
											'<td class="spanDataCenter">'+
												'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' ('+objArray[i].span+')</span>'+
											'</td>'+
											'<td class="spanDataLeft">'+
											'<span>'+toCurrencyString(objArray[i].subList[subRes].paymentAmount)+'</span>'+//
											'</td>'+
											'<td class="spanDataLeft">'+
												'<span>'+toCurrencyString(objArray[i].subList[subRes].defaultCherge-objArray[i].subList[subRes].paymentAmount)+'</span>'+//
											'</td>'+
										'</tr>';
									
									}
									nextNumberResIngroup = objArray[i].subList.length;
							OldGroupId = objArray[i].groupIdString; 
							continue;
						}
					}else{
						var setDateFormat = new Date(objArray[i].date);
						var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
						var ShowNameGuest = "";
						/// Name Empty
						if(objArray[i].name!=undefined){
							ShowNameGuest = objArray[i].name
						}
						///
						if(objArray[i].reservationTitle=="Reserved Rooms"){
							StatusResInGroup = statusResv;
						}else if(objArray[i].reservationTitle=="Checked-out Rooms"){
							StatusResInGroup = statusCheckOut;
						}else if(objArray[i].reservationTitle=="Temp Rooms"){
							StatusResInGroup = statusTempResv;
						}else if(objArray[i].reservationTitle=="Cancel Reservation"){
							StatusResInGroup = statusCancelCheckin;
						}else{
							StatusResInGroup = statusCheckin;
						}
						if(checkBgColorG==0){
							statusRecord = 'dataRecordBot';
							checkBgColorG = 1;
						}else{
							statusRecord = 'dataRecordBot';
							checkBgColorG =0;
						}
						var showDisplayGuestname = "";
						if(ShowNameGuest==""){
							showDisplayGuestname = '<tr clearTr=PaymentTackerReservation class="'+statusRecord+'"   id="btnEditS" >';
						}else{
							showDisplayGuestname = '<tr clearTr=PaymentTackerReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')"  id="btnEditS" >';
						}
							NuberShow++;
							textPaymentTracker += showDisplayGuestname+
							'<td class="spanDataCenter">'+
							NuberShow+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>G'+objArray[i].groupId+'</span>'+
							'</td>'+
							'<td class="spanDataLeft">'+
								'<span class="ownerName" >'+ShowNameGuest+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' ('+objArray[i].span+')</span>'+
							'</td>'+
							'<td class="spanDataLeft">'+
							'<span>'+toCurrencyString(objArray[i].paymentAmount)+'</span>'+//
							'</td>'+
							'<td class="spanDataLeft">'+
								'<span>'+toCurrencyString(objArray[i].defaultCherge-objArray[i].paymentAmount)+'</span>'+//
							'</td>'+
						'</tr>';
					}
				}else{
					res = objArray[i].id;
					var setDateFormat = new Date(objArray[i].date);
					var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
					getStatusResInGroup = objArray[i].reservationTitle;
					if(getStatusResInGroup=="Reserved Rooms"){
						showStatusResInGroup = statusResv;
					}else if(getStatusResInGroup=="Checked-out Rooms"){
						showStatusResInGroup = statusCheckOut;
					}else if(getStatusResInGroup=="Temp Rooms"){
						showStatusResInGroup = statusTempResv;
					}else if(getStatusResInGroup=="Cancel Reservation"){
						showStatusResInGroup = statusCancelCheckin;
					}else{
						showStatusResInGroup = statusCheckin;
					}
					if(setDateFormat.getFormatedString()!=undefined){
						if(checkBgColorG==0){
							statusRecord = 'dataRecordBot';
							checkBgColorG = 1;
						}else{
							statusRecord = 'dataRecordBot';
							checkBgColorG =0;
						}
							NuberShow++;
							textPaymentTracker += '<tr clearTr="PaymentTackerReservation" class="'+statusRecord+'" onclick="if(linkClick){ CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')}" id="btnEditS" >'+
							'<td class="spanDataCenter">'+
								NuberShow+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+objArray[i].id+'</span>'+
							'</td>'+
							'<td class="spanDataLeft">'+
								'<span class="guestName" >'+objArray[i].name+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' ('+objArray[i].span+')</span>'+
							'</td>'+
							'<td class="spanDataLeft">'+
								'<span>'+toCurrencyString(objArray[i].paymentAmount)+'</span>'+//
							'</td>'+
							'<td class="spanDataLeft">'+
								'<span>'+toCurrencyString(objArray[i].defaultCherge-objArray[i].paymentAmount)+'</span>'+//
							'</td>'+
						'</tr>';
					}
				}
			}
			if(textPaymentTracker==""){
				var textDataEmpty = '<tr clearTr="PaymentTackerReservation" >'+
				'<td colspan="100%" style="text-align:center;" >'+
				dataEmpty+
				'</td>'+
				'</tr>';
				textPaymentTracker = textDataEmpty;
			}
			$("#PaymentTrackerListRoomManageMent_Id_Tr").replaceWith("<tr id=PaymentTrackerListRoomManageMent_Id_Tr ></tr>"+textPaymentTracker);
			textPrint = textPaymentTracker;
			textPaymentTracker = "";
	}
	dateRoomManageMent({checkin:"calendar_btw_checkinPaymentTracker",atrcheckin:"dateofBtwCheckinPaymentTracker"},{checkout:"calendar_btw_checkoutPaymentTracker",atrcheckout:"dateofBtwCheckoutPaymentTracker"});
	$(".ui-datepicker-trigger").css("margin-top","2px");
	closeWaitingDialog();
	showDataResRoomManageMentSetPagePaymentTrack(data,getCurrentTabData().linePaymentTracker);
}

function showDataResRoomManageMentSetPagePaymentTrack(data,output){
	$("[clearTr*=paymenttrackReservationPage]").remove();
	objArray = JSON.parse(data);
	objArray = objArray[1];
	var textRoomPaymentTrackSetpage = "";
	for(var i =0;i<objArray.length;i++){
		var textSubRes = "";
		if(objArray[i].groupId!="0"){
			var statusRecord = "";
			for(var subRes = 0;subRes<objArray[i].subList.length;subRes++){
				textSubRes += '<tr clearTr=paymenttrackReservationPage  ><td></td></tr>';
			}
			textRoomPaymentTrackSetpage += '<tr clearTr=paymenttrackReservationPage class="trPaymentTrack"><td></td></tr>'+textSubRes;
		}else{
			textRoomPaymentTrackSetpage += '<tr clearTr=paymenttrackReservationPage ><td></td></tr>';
		}
	}
	$("[name = PaymentTrackerListRoomManageMent_Id_Tr2]").replaceWith("<tr name=PaymentTrackerListRoomManageMent_Id_Tr2 ></tr>"+textRoomPaymentTrackSetpage);
	textRoomPaymentTrackSetpage = "";
	textSubRes = "";
	
	showPager(output);
}

function showDataResRoomManageMentSetCountPaymentTrack(data,output){
	var subCount = 0;
	var recCount = 0;
	var objArray = new Array();
	if((data=="textSearch"||data=="G"||data=="S"||data=="A"||data=="reservationType_A"||data=="Checked-out Rooms"||data=="Checked-in Rooms")&&data!="dateSearch"){
		objArray = oldObjAroldObjArrayPaymentTrackerrayCheckin;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}else{
		objArray = JSON.parse(data);
		oldObjArrayPaymentTracker = objArray;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}
	setoldObjArrayPaymentTracker = objArray;
	sortIdRoommanagement(objArray);
	sortIdRoommanagement(objArrayCheck);
	for(var i =0;i<objArray.length;i++){
		if(objArray[i].groupId!="0"){
			if(objArray[i].subList!=undefined){
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					
					recCount = recCount+objArrayCheck[objArrayCheck.length-1].subList.length;
				//	subCount = objArrayCheck[objArrayCheck.length-1].subList.length+1;
					break;
				}else{
					recCount += objArray[i].subList.length;
				}
			}else{
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					recCount = (i+1);
					break;
				}else{
					recCount++;
				}
			}
		}else{
			if(objArrayCheck[objArrayCheck.length-1].id==objArray[i].id){
				
				recCount = recCount+1;
				break;
			}else{
				recCount++;
			}
		}
	}
	getCurrentTabData().beforePagePaymentTracker = (recCount);
	getCurrentTabData().beforeSubPagePaymentTracker = subCount;
	simpleservice(getCurrentTabData().linkSet,null,showDataResRoomPaymentTrackerManageMent,data);
}

function typeReservationPaymentTrackFunction(dataOld,offfset,pagePointer,dateCheckin,dateCheckout,data,searchName){
	var valueDateCheckin = getCurrentTabData().valueDateCheckin;
	var valueDateCheckout = getCurrentTabData().valueDateCheckout;
	if((valueDateCheckin!=""&&valueDateCheckout!="")&&(valueDateCheckin!=undefined&&valueDateCheckout!=undefined)){
		if(dataOld=="G"){
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
			}else{
				getCurrentTabData().beforePagePaymentTracker = ""; 
				getCurrentTabData().beforeSubPagePaymentTracker = "";
				var link = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
			}
		}else if(dataOld=="S"){
			getCurrentTabData().typeReservationPaymentTrack = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
			}else{
				getCurrentTabData().beforePagePaymentTracker = ""; 
				getCurrentTabData().beforeSubPagePaymentTracker = "";
				var link = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
			}
		}else if(dataOld=="A"){
			getCurrentTabData().typeReservationPaymentTrack = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationAllPaymentTracker&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1)+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				var linkSet = "/reservationService?func=getReservationAllPaymentTracker&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
			}else{
				getCurrentTabData().beforePagePaymentTracker = ""; 
				getCurrentTabData().beforeSubPagePaymentTracker = "";
				var link = "/reservationService?func=getReservationAllPaymentTracker&offset="
					+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer+"&dateCheckin="+dateCheckin+"&dateCheckout="+dateCheckout+"&SearchAll_checkoutPage="+searchName;
				simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
			}
		}
	}else{
		if(dataOld=="G"){
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1);
				var linkSet = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
			}else{
				getCurrentTabData().beforePagePaymentTracker = ""; 
				getCurrentTabData().beforeSubPagePaymentTracker = "";
				var link = "/reservationService?func=getReservationAllPaymentTrackerGroup&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer;
				simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
			}
		}else if(dataOld=="S"){
			getCurrentTabData().typeReservationPaymentTrack = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1);
				var linkSet = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
			}else{
				getCurrentTabData().beforePagePaymentTracker = ""; 
				getCurrentTabData().beforeSubPagePaymentTracker = "";
				var link = "/reservationService?func=getReservationAllPaymentTrackerSingle&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer;
				simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
			}
		}else if(dataOld=="A"){
			getCurrentTabData().typeReservationPaymentTrack = dataOld;
			if(pagePointer>1){
				var link = "/reservationService?func=getReservationAllPaymentTracker&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+(pagePointer-1);
				var linkSet = "/reservationService?func=getReservationAllPaymentTracker&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer;
				getCurrentTabData().linkSet = linkSet;
				simpleservice(link,null,showDataResRoomManageMentSetCountPaymentTrack,getCurrentTabData().linePaymentTracker);
			}else{
				getCurrentTabData().beforePagePaymentTracker = ""; 
				getCurrentTabData().beforeSubPagePaymentTracker = "";
				var link = "/reservationService?func=getReservationAllPaymentTracker&offset="+offfset+"&line="+getCurrentTabData().linePaymentTracker+"&pagePointer="+pagePointer;
				simpleservice(link,null,showDataResRoomPaymentTrackerManageMent,data);
			}
		}
	}
}
